home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2008 October / MacFormat Issue200 October 2008.toast / pc / DiscContents / In the mag / Cover feature / iStat pro 4.7 / Widget / iStat pro.wdgt / DiskObject.js < prev    next >
Encoding:
Text File  |  2008-07-09  |  5.6 KB  |  147 lines

  1. function TallDiskObject(top, data){
  2.     var _self = this;
  3.     this.container = document.createElement('div');
  4.     this.container.setAttribute ("style", "top:" + top + "px;clear:both;left:20px;position:absolute;height:31px;width:125px;overflow:hidden");
  5.     document.getElementById("tall_disk_container").appendChild(this.container);
  6.     
  7.     this.name = document.createElement('div');
  8.     this.name.setAttribute ("style", "position:absolute;top:0px;color:white;color:white;width:110px;overflow:hidden;height:12px;");
  9.     this.name.setAttribute ("class", "ellipsis");
  10.     this.container.appendChild(this.name);
  11.  
  12.     var used_container = document.createElement('div');
  13.     used_container.setAttribute ("style", "width:90px;position:absolute;top:11px;color:white;color: #838383;");
  14.     used_container.setAttribute ("class", "ellipsis");
  15.     this.container.appendChild(used_container);
  16.     
  17.     this.used = document.createElement('span');
  18.     used_container.appendChild(this.used);
  19.  
  20.     var used_suffix = document.createElement('span');
  21.     used_suffix.innerHTML = " used";
  22.     used_container.appendChild(used_suffix);
  23.  
  24.     var free_container = document.createElement('div');
  25.     free_container.setAttribute ("style", "width:90px;position:absolute;top:21px;color:white;color: #838383;");
  26.     free_container.setAttribute ("class", "ellipsis");
  27.     this.container.appendChild(free_container);
  28.     
  29.     this.free = document.createElement('span');
  30.     free_container.appendChild(this.free);
  31.  
  32.     var free_suffix = document.createElement('span');
  33.     free_suffix.innerHTML = " free";
  34.     free_container.appendChild(free_suffix);
  35.     
  36.     var graph_container = document.createElement('div');
  37.     graph_container.setAttribute ("style", "left:116px;position:absolute;top:2px;height:30px;");
  38.     graph_container.setAttribute ("class", "verticalbarbg");
  39.     this.container.appendChild(graph_container);
  40.  
  41.     this.graph = document.createElement('div');
  42.     this.graph.setAttribute ("style", "position:absolute;bottom:0px;");
  43.     this.graph.setAttribute ("class", "verticalbar");
  44.     graph_container.appendChild(this.graph);
  45.  
  46.     this.icon = document.createElement('img');
  47.     this.icon.setAttribute ("style", "height:20px;width:20px;position:absolute;top:12px;left:93px;z-index:10;");
  48.     this.icon.src = './images/defaultHD.png';
  49.     this.container.appendChild(this.icon);
  50.     this.icon.onclick = function(){ _self.openDisk();};
  51.     this.icon.setAttribute("class", "diskicon");
  52.  
  53.     this.divider = document.createElement('div');
  54.     this.divider.setAttribute ("style", "position:relative;clear:both;left:0px;background-image:url(./images/skin_tall_blaqua/menu_divider.png);width:176px;height:14px;");
  55.     document.getElementById("tall_disk_container").appendChild(this.divider);
  56. }
  57.  
  58. TallDiskObject.prototype.openDisk = function(){
  59.     iStatPro.openDisk(this.path);
  60.     widget.openURL('');
  61. }
  62.  
  63. TallDiskObject.prototype.updateWithData = function(data){
  64.     this.name.innerText = data[0];
  65.     this.used.innerHTML = data[2];    
  66.     this.free.innerHTML = data[3];    
  67.     this.path = escape(data[4]);
  68.         
  69.     var barHeight = data[1] * 0.3;
  70.     if(barHeight < 2 && Math.ceil(parseFloat(data[2])) != 0)
  71.         barHeight = 2;
  72.         
  73.     this.graph.style.height = barHeight;
  74.     this.icon.src = data[5];
  75. }
  76.  
  77. function WideDiskObject(rootContainer, data){
  78.     var _self = this;
  79.     var container = document.createElement('div');
  80.     container.setAttribute ("style", "overflow:hidden;clear:both;height:45px;width:82px;position:relative;");
  81.     rootContainer.appendChild(container);                
  82.  
  83.     this.name = document.createElement('div');
  84.     this.name.setAttribute ("class", "ellipsis");
  85.     this.name.setAttribute ("style", "position:absolute;top:0px;color:white;color:white;width:82px;overflow:hidden;height:12px;");
  86.     container.appendChild(this.name);
  87.  
  88.     var used_container = document.createElement('div');
  89.     used_container.setAttribute ("class", "ellipsis");
  90.     used_container.setAttribute ("style", "width:60px;position:absolute;top:11px;color:white;color: #838383;");
  91.     container.appendChild(used_container);
  92.  
  93.     var used_suffix = document.createElement('span');
  94.     used_suffix.innerText = 'U: ';
  95.     used_container.appendChild(used_suffix);
  96.  
  97.     this.used = document.createElement('span');
  98.     used_container.appendChild(this.used);
  99.  
  100.     var free_container = document.createElement('div');
  101.     free_container.setAttribute ("class", "ellipsis");
  102.     free_container.setAttribute ("style", "width:60px;position:absolute;top:21px;color:white;color: #838383;");
  103.     container.appendChild(free_container);
  104.  
  105.     var free_suffix = document.createElement('span');
  106.     free_suffix.innerText = 'F: ';
  107.     free_container.appendChild(free_suffix);
  108.  
  109.     this.free = document.createElement('span');
  110.     free_container.appendChild(this.free);
  111.  
  112.     var graph_container = document.createElement('div');
  113.     graph_container.setAttribute ("style", "position:absolute;top:35px;color:white;width:82px;");
  114.     graph_container.setAttribute ("class", "barbg");
  115.     container.appendChild(graph_container);
  116.  
  117.     this.graph = document.createElement('div');
  118.     this.graph.setAttribute ("class", "graphbar");
  119.     graph_container.appendChild(this.graph);
  120.  
  121.     this.icon = document.createElement('img');
  122.     this.icon.setAttribute ("style", "height:22px;width:22px;position:absolute;top:13px;left:60px;z-index:10;");
  123.     this.icon.src = './images/defaultHD.png';
  124.     container.appendChild(this.icon);
  125.     this.icon.onclick = function(){ _self.openDisk();};
  126.     this.icon.setAttribute("class", "diskicon");
  127. }
  128.  
  129. WideDiskObject.prototype.openDisk = function(){
  130.     iStatPro.openDisk(this.path);
  131.     widget.openURL('');
  132. }
  133.  
  134. WideDiskObject.prototype.updateWithData = function(data){
  135.     this.name.innerText = data[0];
  136.     this.used.innerHTML = data[2];    
  137.     this.free.innerHTML = data[3];
  138.     this.path = escape(data[4]);
  139.         
  140.     var barWidth = data[1] * 0.82;
  141.     if(barWidth < 1 && Math.ceil(parseFloat(data[2])) != 0)
  142.         barWidth = 1;
  143.         
  144.     this.graph.style.width = barWidth;
  145.     this.icon.src = data[5];
  146. }
  147.